#include "StockAssist.h"

CStockAssist::CStockAssist(void)
{
}

CStockAssist::~CStockAssist(void)
{
}

bool CStockAssist::GroupStockCode( uint16 wMarket,char* m_szLabel, std::string& strCode )
{
	if (wMarket == SH_MARKET_EX)
	{
		strCode = "SH";
		strCode += m_szLabel;
		return true;
	}
	else if (wMarket == SZ_MARKET_EX)
	{
		strCode = "SZ";
		strCode += m_szLabel;
		return true;
	}
	else
	{
		return false;
	}
}

bool CStockAssist::Split( std::string strCode, uint16& wMarket, char*& szLabel)
{
	wMarket = SH_MARKET_EX;
	if (strCode.find("SH") != std::string::npos)
	{
		wMarket = SH_MARKET_EX;
	}
	else if (strCode.find("SZ") != std::string::npos)
	{
		wMarket = SZ_MARKET_EX;
	}
	else
	{
		return false;
	}
	strCode = strCode.substr(2);
	memset(szLabel, 0, strCode.length() + 1);
	memcpy(szLabel, strCode.c_str(), strCode.length());
	return true;
}
